/**
 * 格式化节点关系图
 * @des {
 *   仅格式化组件所需要的数据
 * }
 */
import { $isEmptyArr } from '../index';
export function relationFormat (datasets) {
  const { source, type } = datasets;
  const seriesData = [];
  const { data = [], links = [] } = source[0] || {};
  // data数据去重, 防止name重复而保错
  const dataMap = new Map();
  const dataValue = data.filter(item => !dataMap.has(item.name) && dataMap.set(item.name, 1));
  if(!$isEmptyArr(source) && type === 'STATIC') {
    seriesData.push({data: dataValue, links});
  }
  return { seriesData }
};
